﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WebNetCorePhoneErp.Model;
using WebNetCorePhoneErp.Model.Tool;

namespace WebNetCorePhoneErp.DAL
{
    public class MyDbContext: DbContext
    {
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            //连接字符串配置
            string connectionString = MyConfigReader.GetConfigValue("connctionDb");
            optionsBuilder.UseSqlServer(connectionString);

            //设置不跟踪所有查询  
            optionsBuilder.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking);

            //启用敏感数据日志记录
            optionsBuilder.EnableSensitiveDataLogging();

#if DEBUG
            //记录日志          
            optionsBuilder.LogTo(msg =>
            {
                //调试-窗口消息
                System.Diagnostics.Debug.WriteLine(msg);
                //输出-窗口消息
                Console.WriteLine(msg);
            });
#endif

        }


        public virtual DbSet<Brand> Brand { get; set; }
        public virtual DbSet<Category> Category { get; set; }
        public virtual DbSet<Employee> Employee { get; set; }
        public virtual DbSet<G_good> G_goods { get; set; }
        public virtual DbSet<Goods_photo> Goods_photo { get; set; }
        public virtual DbSet<Login_log> Login_log { get; set; }
        public virtual DbSet<Operate_log> Operate_log { get; set; }
        public virtual DbSet<Role_function> Role_function { get; set; }
        public virtual DbSet<Role_list> Role_list { get; set; }
        public virtual DbSet<Sale_record> Sale_record { get; set; }

    }
}
